package com.struct.graph.loader
{
	import com.component.ComponentChildren;
	import com.core.Application;
	import com.events.UIComponentEvent;
	import com.utils.Utils;
	
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	public class LoaderFrame extends ComponentChildren
	{
		public var txtName:TextField;
		public var txtProgress:TextField;
		private var application:Application;
		public function LoaderFrame()
		{
			super();
			application = SSA.application;
			txtName = Utils.createTextField(this, 0, 0, "正在加载：xxx", 12, 0, true, TextFieldAutoSize.CENTER, 300);
			txtProgress = Utils.createTextField(this, 0, 0, "已加载：50%", 12, 0, true, TextFieldAutoSize.CENTER, 300);
			drawBackground();
			application.addEventListener(UIComponentEvent.CHANGE, changeHandler);
		}
		
		private function changeHandler(e:UIComponentEvent):void{
			drawBackground();
		}
		private function drawBackground():void{
			width = application.width;
			height = application.height;
			txtName.x = txtProgress.x = (width - 300) / 2;
			txtName.y = (height / 2) - 30;
			txtProgress.y = txtName.y + 25;
			graphics.clear();
			graphics.beginFill(0x00, .4);
			graphics.drawRect(0, 0, width, height);
			graphics.endFill();
		}
		
		public function setShowInfo(name:String, progress:String):void{
			txtName.text = "正在加载：" + name;
			txtProgress.text = "已加载：" + progress;
		}
	}
}